{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #拿硬币"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array #math"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组 #数学"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: minCount"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #拿硬币"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>桌上有 <code>n</code> 堆力扣币，每堆的数量保存在数组 <code>coins</code> 中。我们每次可以选择任意一堆，拿走其中的一枚或者两枚，求拿完所有力扣币的最少次数。</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<blockquote>\n",
    "<p>输入：<code>[4,2,1]</code></p>\n",
    "\n",
    "<p>输出：<code>4</code></p>\n",
    "\n",
    "<p>解释：第一堆力扣币最少需要拿 2 次，第二堆最少需要拿 1 次，第三堆最少需要拿 1 次，总共 4 次即可拿完。</p>\n",
    "</blockquote>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<blockquote>\n",
    "<p>输入：<code>[2,3,10]</code></p>\n",
    "\n",
    "<p>输出：<code>8</code></p>\n",
    "</blockquote>\n",
    "\n",
    "<p><strong>限制：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= n &lt;= 4</code></li>\n",
    "\t<li><code>1 &lt;= coins[i] &lt;= 10</code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [na-ying-bi](https://leetcode.cn/problems/na-ying-bi/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [na-ying-bi](https://leetcode.cn/problems/na-ying-bi/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[4,2,1]', '[2,3,10]']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum([x//2 + x % 2 for x in coins])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for coin in coins:\n",
    "            ans += coin//2+1 if coin%2 == 1 else coin // 2\n",
    "        return ans "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans=0\n",
    "        for i in coins:\n",
    "            ans+=math.ceil(i/2)\n",
    "        return ans\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        from math import ceil\n",
    "        cnt = 0\n",
    "        for i in coins:\n",
    "            cnt += ceil(i / 2)\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        result=0\n",
    "        for i in range(len(coins)):\n",
    "          if coins[i]%2==0:\n",
    "             result+=coins[i]//2\n",
    "          else:\n",
    "            result+=coins[i]//2+1\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        c = 0\n",
    "        for coin in coins:\n",
    "            n = (coin + 1) // 2\n",
    "            c += n\n",
    "        return c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for coin in  coins:\n",
    "            ans += (coin + 1) // 2\n",
    "        \n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum([round(x/2+0.1) for x in coins])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        res = 0\n",
    "        for c in coins:\n",
    "            res += (c + 1) // 2\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum(sum(divmod(coin, 2))for coin in coins)\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans=0\n",
    "        for i in range(0,len(coins)):\n",
    "            ans=ans+coins[i]//2+coins[i]%2\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for x in coins:\n",
    "            ans += x // 2 + (1 if x % 2 == 1 else 0)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum(coin//2 if coin%2==0 else coin//2+1 for coin in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for i in coins:\n",
    "            ans += (i+1) // 2\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum((i + 1) >> 1 for i in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for i in coins:\n",
    "            ans += ceil(i/2)\n",
    "\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        res = 0\n",
    "        for i in coins:\n",
    "            res += i // 2 if i % 2 == 0 else i // 2 + 1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        cnt = 0\n",
    "        for coin in coins:\n",
    "            cnt += coin // 2\n",
    "            cnt += coin % 2\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        res = 0\n",
    "        for coin in coins:\n",
    "            if (coin % 2 == 0):\n",
    "                res += int(coin / 2)\n",
    "            else:\n",
    "                res += int(coin / 2) + 1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum((i + 1) // 2 for i in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        t = 0\n",
    "        for i in coins:\n",
    "            a = i // 2\n",
    "            if a * 2 == i:\n",
    "                t += a\n",
    "            else:\n",
    "                t += a + 1\n",
    "        return t\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum(list((map(lambda x:int(x/2+x%2),coins))))\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for i in coins:\n",
    "            if i % 2 == 0:\n",
    "                ans += i // 2\n",
    "            else:\n",
    "                ans += i // 2 + 1\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        sum=0\n",
    "        for i in range(len(coins)):\n",
    "            if(coins[i]%2==0):\n",
    "                sum+=coins[i]/2\n",
    "            elif(coins[i]%2):\n",
    "                sum+=coins[i]//2+1\n",
    "        return int(sum)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        sum = 0\n",
    "        for i in coins:\n",
    "            a,b = divmod(i,2)\n",
    "            sum += a+b\n",
    "        return sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        res = 0\n",
    "        for x in coins:\n",
    "            res += ( x + 1 ) // 2\n",
    "        return res \n",
    "\n",
    "         "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        n = 0\n",
    "        for i in coins:\n",
    "            if i % 2 == 0:\n",
    "                n += (i // 2)\n",
    "            else:\n",
    "                n += (i // 2) + 1\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        sum = 0\n",
    "        for i in coins:\n",
    "            if i % 2:\n",
    "                sum += i // 2 + 1\n",
    "            else:\n",
    "                sum += i // 2\n",
    "        return sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        result=0\n",
    "        for i in coins:\n",
    "            if i<=2:\n",
    "                result=result+1\n",
    "            else:\n",
    "                if i%2==0:\n",
    "                    result=i//2+result\n",
    "                else:\n",
    "                    result=i//2+1+result\n",
    "        print(result)\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        sum = 0\n",
    "        for c in coins:\n",
    "            if c % 2:\n",
    "                sum += c // 2 + 1\n",
    "            else:\n",
    "                sum += c //2\n",
    "        return sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans=0\n",
    "        for i in coins:\n",
    "            if i%2 ==1:\n",
    "                ans+=i//2+1\n",
    "            else: ans+=i//2\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        l = len(coins)\n",
    "        m = 0\n",
    "        for i in range(l):\n",
    "            while coins[i] > 0:\n",
    "                if coins[i] == 1:\n",
    "                    coins[i] -= 1\n",
    "                    m += 1\n",
    "                else:\n",
    "                    coins[i] -=2\n",
    "                    m += 1 \n",
    "        return m\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        import math\n",
    "        result = 0\n",
    "        for i in coins:\n",
    "            result += math.ceil(i/2)\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        # def getnum(num):\n",
    "        #     if num % 2== 0:\n",
    "        #         return num // 2\n",
    "        #     else:\n",
    "        #         return (num // 2) + 1\n",
    "        \n",
    "        # return sum(map(getnum,coins))\n",
    "        return sum((i+1)//2 for i in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        sum=0\n",
    "        for c in coins:\n",
    "            sum+=(c+1)//2\n",
    "        return sum       "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum([(coin+1)>>1 for coin in coins])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans=0\n",
    "        for i in coins:\n",
    "            if i&1:\n",
    "                ans+=(i+1)/2\n",
    "            else:\n",
    "                ans+=i/2\n",
    "        return int(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans=0\n",
    "        for i in coins:\n",
    "            if i%2 ==1:\n",
    "                ans+=i//2+1\n",
    "            else: ans+=i//2\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for i in coins:\n",
    "            if i <= 2:\n",
    "                ans += 1\n",
    "            if i > 2 :\n",
    "                if i % 2 == 0:\n",
    "                    ans += i/2\n",
    "                elif i % 2 != 0:\n",
    "                    ans += (i // 2) + 1\n",
    "        return int(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        sum = 0 \n",
    "        for a in coins:\n",
    "            if a % 2 ==1 :\n",
    "                sum += a // 2 + 1\n",
    "            else :\n",
    "                sum += a//2\n",
    "        return sum \n",
    "#法二：\n",
    "'''   def minCount(self, coins: List[int]) -> int:\n",
    "        sum = 0 \n",
    "        for a in coins:\n",
    "           sum += (a+1)//2\n",
    "        return sum'''\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        sum = 0\n",
    "        for i in coins:\n",
    "            sum+=(i+1)//2\n",
    "        return sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        sum = 0\n",
    "        for i in coins:\n",
    "            if i % 2:\n",
    "                sum += i //2 +1\n",
    "            else:\n",
    "                sum += i // 2\n",
    "        return sum "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum((x + 1) >> 1 for x in coins)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for i in coins:\n",
    "            ans += ceil(i / 2)\n",
    "        return ans\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "import math\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum(math.ceil(int((i+1)/2)) for i in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        cnt = 0\n",
    "        for i in coins:\n",
    "            if i % 2 == 0:\n",
    "                cnt += i//2\n",
    "            else:\n",
    "                cnt += i//2 + 1\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum((x + 1) // 2 for x in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        a = 0\n",
    "        for i in coins:\n",
    "            a += (i+1)//2\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "\n",
    "        def greedy_pick(coin):\n",
    "            return coin % 2 + coin // 2\n",
    "        ans = 0\n",
    "        for c in coins:\n",
    "            ans += greedy_pick(c)\n",
    "        \n",
    "        return ans\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "import math\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        result = 0\n",
    "        for pile in coins:\n",
    "            result += math.ceil(pile/2)\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum((i + 1) // 2 for i in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum([x//2 + x % 2 for x in coins])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        count = 0\n",
    "        for i in coins:\n",
    "            if i%2 != 0 :\n",
    "                temp = int(i/2) + 1\n",
    "            else:\n",
    "                temp = int(i/2)\n",
    "            count +=temp\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        res = 0\n",
    "        for var in coins:\n",
    "            if var % 2 == 0:\n",
    "                res += (var // 2)\n",
    "            else:\n",
    "                res += 1\n",
    "                res += ((var-1)//2)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        c = 0\n",
    "        for i in range(len(coins)):\n",
    "            a = (coins[i]+1) // 2\n",
    "            c+=a\n",
    "        return c\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum((i + 1) // 2 for i in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        # result = 0\n",
    "        # for coin in coins:\n",
    "        #     if coin % 2 == 0:\n",
    "        #         result += coin // 2\n",
    "        #     else:\n",
    "        #         result += coin // 2 + 1\n",
    "        # return result\n",
    "        return sum(int(i/2 + 0.5) for i in coins)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum([c//2+c%2 for c in coins])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        count = 0\n",
    "        for i in coins:\n",
    "            count += math.ceil(i/2) \n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        num = 0\n",
    "        for i in coins:\n",
    "            if i % 2 == 0:\n",
    "                num += i/2\n",
    "            else:\n",
    "                num += (i+1)/2\n",
    "        return int(num)\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        cnt = 0\n",
    "        for _ in coins:\n",
    "            cnt += int((_+1)/2)\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum((x + 1) // 2 for x in coins)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "#        sum = 0\n",
    "#        for i in coins:\n",
    "#            if i == 1:\n",
    "#                sum += 1\n",
    "#            elif i % 2 == 0:\n",
    "#                sum += i/2\n",
    "#            else:\n",
    "#                sum += i/2+1\n",
    "#        return int(sum)\n",
    "\n",
    "        return sum((i + 1) // 2 for i in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum([(i+1)//2 for i in coins])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        result=0\n",
    "        for c in coins:\n",
    "            result+=(c+1)//2\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        res = 0\n",
    "        for val in coins:\n",
    "            res +=  val // 2\n",
    "            res += val % 2\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        res=0\n",
    "        for x in coins:\n",
    "            if x%2==0:\n",
    "                res+=x//2\n",
    "            else:\n",
    "                res+=x//2+1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "\n",
    "        counter = 0\n",
    "        for i in range(len(coins)):\n",
    "            while coins[i] > 0:\n",
    "                if coins[i] % 2==0:\n",
    "                    coins[i] -= 2\n",
    "                    counter += 1\n",
    "                else:\n",
    "                    coins[i] -= 1\n",
    "                    counter += 1\n",
    "        return counter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        a = 0\n",
    "        for i in coins:\n",
    "            if i % 2 == 0:\n",
    "                a += i / 2\n",
    "            else:\n",
    "                a += (i // 2) + 1\n",
    "        return int(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        result = 0\n",
    "        for coin in coins:\n",
    "            if coin % 2 == 0:\n",
    "                result += coin // 2\n",
    "            else:\n",
    "                result += coin // 2 + 1\n",
    "        return result\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        time = 0\n",
    "        for each in coins:\n",
    "            if each%2 == 0:\n",
    "                time = time + each/2\n",
    "            else:\n",
    "                time = time + (each+1) /2\n",
    "        return int(time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        n=len(coins)\n",
    "        s=0\n",
    "        for i in range(n):\n",
    "            if coins[i]%2==0:\n",
    "                a=coins[i]/2\n",
    "                s+=a\n",
    "            else:\n",
    "                a=int(coins[i]/2+1)\n",
    "                s+=a\n",
    "        return int(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        sum = 0\n",
    "        for i in coins:\n",
    "            sum += (i+1)//2\n",
    "        return sum "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        steps = 0\n",
    "        for i in coins:\n",
    "            if i % 2 == 0:\n",
    "                steps += i//2\n",
    "            else:\n",
    "                steps += (i//2) + 1\n",
    "        return steps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "       return sum((x + 1) // 2for x in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum(c + 1 >> 1 for c in coins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minCount(self, coins: List[int]) -> int:\n",
    "        return sum((x + 1) >> 1 for x in coins)\n"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
